import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextLong();
        }

        //创建前缀和数组
        long[] dp = new long[n + 1];
        for (int i = 1; i < n + 1; i++) {
            dp[i] = dp[i - 1] + arr[i - 1];
        }


        long[] max = new long[n + 1];
        long[] min = new long[n + 1];

//        max[n + 1] = Integer.MIN_VALUE;//max的最后一个数不能影响前面的数
        max[n] = dp[n];
        for (int i = n - 1; i > 0; i--) {
            max[i] = Math.max(max[i + 1], dp[i]);
        }

//        min[1] = dp[1];
        for (int i = 1; i < n + 1; i++) {
            min[i] = Math.min(min[i - 1], dp[i]);
        }

//        System.out.println(Arrays.toString(max));
//        System.out.println(Arrays.toString(min));

        for (int i = 1; i < n + 1; i++) {
            System.out.print(max[i] - min[i - 1] + " ");
        }

        scanner.close();

    }
}
